package com.qingyi.mall.coupon.controller;

import java.util.Arrays;
import java.util.Map;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import com.qingyi.mall.coupon.entity.PmsAttrGroupEntity;
import com.qingyi.mall.coupon.service.PmsAttrGroupService;
import com.qingyi.mall.common.utils.PageUtils;
import com.qingyi.mall.common.utils.R;



/**
 * 属性分组
 *
 * @author qingyi
 * @email qingyi@gmail.com
 * @date 2020-07-12 19:59:59
 */
@RestController
@RequestMapping("coupon/pmsattrgroup")
@Api(tags = "属性分组")
public class PmsAttrGroupController {
    @Autowired
    private PmsAttrGroupService pmsAttrGroupService;

    /**
     * 列表
     */
    @RequestMapping(value = "/list",method = RequestMethod.GET)
    @ApiOperation(value = "获取列表",notes = "获取属性分组的列表")
    //@RequiresPermissions("coupon:pmsattrgroup:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = pmsAttrGroupService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping(value = "/info/{attrGroupId}",method = RequestMethod.GET)
    @ApiOperation(value = "信息",notes = "获取属性分组的信息")
    //@RequiresPermissions("coupon:pmsattrgroup:info")
    public R info(@PathVariable("attrGroupId") Long attrGroupId){
		PmsAttrGroupEntity pmsAttrGroup = pmsAttrGroupService.getById(attrGroupId);

        return R.ok().put("pmsAttrGroup", pmsAttrGroup);
    }

    /**
     * 保存
     */
    @RequestMapping(value = "/save",method = RequestMethod.POST)
    @ApiOperation(value = "保存",notes = "保存属性分组的信息")
    //@RequiresPermissions("coupon:pmsattrgroup:save")
    public R save(@RequestBody PmsAttrGroupEntity pmsAttrGroup){
		pmsAttrGroupService.save(pmsAttrGroup);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping(value = "/update",method = RequestMethod.PUT)
    @ApiOperation(value = "修改",notes = "修改属性分组的信息")
    //@RequiresPermissions("coupon:pmsattrgroup:update")
    public R update(@RequestBody PmsAttrGroupEntity pmsAttrGroup){
		pmsAttrGroupService.updateById(pmsAttrGroup);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping(value = "/delete",method = RequestMethod.DELETE)
    @ApiOperation(value = "修改",notes = "修改属性分组的信息")
    //@RequiresPermissions("coupon:pmsattrgroup:delete")
    public R delete(@RequestBody Long[] attrGroupIds){
		pmsAttrGroupService.removeByIds(Arrays.asList(attrGroupIds));

        return R.ok();
    }

}
